<template>
    <div class="add">
      <div class="add-top">
        <div style="background-color: #fff; width: 80px; text-align: center;">
          <span style="font-size: 18px; color: blue;">新增单元</span>
        </div>
      </div>
      <div class="mid">
        <el-form
          ref="form"
          :model="formData"
          label-width="100px"
          class="demo-ruleForm"
          :rules="rules"
        >
          <div class="form-row">
            <el-form-item label="小区名称" prop="xiaoqu">
              <el-input
                v-model="formData.communityname"
                style="width: 400px; margin-right: 20px;"
              ></el-input>
            </el-form-item>
            <el-form-item label="单元名称" prop="danyuan">
              <el-input
                v-model="formData.unitname"
                style="width: 400px; margin-right: 20px;"
              ></el-input>
            </el-form-item>
          </div>
          <div class="form-row">
            <el-form-item label="栋数" prop="dongshu">
              <el-input
                v-model="formData.unitnum"
                style="width: 400px; margin-right: 20px;"
              ></el-input>
            </el-form-item>
            <el-form-item label="状态选择" prop="type">
              <el-select
                v-model="formData.type"
                placeholder="请选择状态"
                style="width: 400px; margin-right: 20px;"
              >
                <el-option
                  v-for="item in typeList"
                  :key="item.value"
                  :label="item.text"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </div>
        </el-form>
      </div>
    </div>
  </template>
  
  <script>
  export default {
    data() {
      return {
        typeList: [
          {
            text: "已建成",
            value: "1"
          },
          {
            text: "未建成",
            value: "2"
          }
        ],
        formData: {
          communityname: "",
          unitname: "",
          unitnum: "",
          type: ""
        },
        rules: {
          xiaoqu: [
            { required: true, message: "小区名称不能为空", trigger: "blur" }
          ],
          danyuan: [
            { required: true, message: "单元名称不能为空", trigger: "blur" }
          ],
          dongshu: [
            { required: true, message: "栋数不能为空", trigger: "blur" }
          ],
          type: [
            { required: true, trigger: "blur" }
          ],
        }
      };
    }
  };
  </script>
  
  <style scoped>
  .add {
    border: 1px solid #efefef;
  }
  .add-top {
    height: 35px;
    line-height: 35px;
    background-color: #efefef;
  }
  .mid {
    padding: 20px;
  }
  .form-row {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 20px;
  }
  .el-form-item {
    flex: 0 0 50%;
    box-sizing: border-box;
    padding-right: 20px;
  }
  </style>